/*
 * File:   addTemplateDialog.cpp
 * Author: nicolas
 *
 * Created on 17 février 2013, 12:42
 */

#include "addTemplateDialog.h"

addTemplateDialog::addTemplateDialog(accueil* parent) {
    widget.setupUi(this);
    parent_=parent;
    QObject::connect(widget.addTempBtn, SIGNAL(clicked()), this, SLOT(addListListener()));
}

addTemplateDialog::addTemplateDialog(accueil* parent, ListOfTask* list) {
    widget.setupUi(this);
    parent_=parent;
    list_=list;
    
    string nomList = list_->getName();
    widget.listName->setText(QString(nomList.c_str()));
   
    
    QObject::connect(widget.addTempBtn, SIGNAL(clicked()), this, SLOT(modifyListListener()));
}

addTemplateDialog::~addTemplateDialog() {
}

void addTemplateDialog::addListListener() {

    parent_->addTemplate(widget.listName->text().toStdString());
    accept();

}

void addTemplateDialog::modifyListListener() {
   
    list_->setName(widget.listName->text().toStdString());
    parent_->modifyTemplate(widget.listName->text().toStdString());
    accept();
}